<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- AUTHOR: Jason -->
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      >
    <body>
        <ui:composition>
            <h:form>
                <p:panel>
                    <p:remoteCommand name="updateAttendance" update="@form"/>
                    <h:panelGrid columns="2">
                        <h:panelGroup>
                            <h:panelGrid columns="2">
                                <h:panelGrid columns="2">
                                    <h:outputLabel id="addDateLabel" value="Specify a date:"/>
                                    <p:calendar id="addDate" value="#{attendanceBean.addDate}" showOn="button"/>
                                </h:panelGrid>
                                <h:panelGrid columns="2">
                                    <h:outputLabel id="removeDateLabel" value="Specify a date:"/>
                                    <p:calendar id="removeDate" value="#{attendanceBean.removeDate}" showOn="button"/>
                                </h:panelGrid>

                                <h:selectManyListbox id="add" size ="10" value="#{attendanceBean.addAttendance}">
                                    <f:selectItems value="#{attendanceBean.addClassRole}"/>
                                </h:selectManyListbox>
                                <h:selectManyListbox id="remove" size ="10" value="#{attendanceBean.removeAttendance}">
                                    <f:selectItems value="#{attendanceBean.removeClassRole}"/>
                                </h:selectManyListbox>

                                <p:commandButton value="Add Attendance" process="@form" update=":tabForm:growl" oncomplete="updateAttendance();" action="#{attendanceBean.addSelectedAttendance}" />
                                <p:commandButton value="Remove Attendance" process="@form" update=":tabForm:growl" oncomplete="updateAttendance();" action="#{attendanceBean.removeSelectedAttendance}" />
                            </h:panelGrid>
                            <p:fieldset legend="Attendance Summary">
                                <p:dataTable id="attendanceSummaryTable" value="#{attendanceBean.attendanceSummaryTableList}" var="attendanceSummary">
                                    <p:column headerText="Last Name">
                                        <h:outputText value="#{attendanceSummary.lastName}" />
                                    </p:column>
                                    <p:column headerText="First Name">
                                        <h:outputText value="#{attendanceSummary.firstName}" />
                                    </p:column>
                                    <p:column headerText="Attendance Count">
                                        <h:outputText value="#{attendanceSummary.attendanceCount}"/>
                                    </p:column>
                                    <p:column headerText="Percentage">
                                        <h:outputText value="#{attendanceSummary.percentage}" />
                                    </p:column>
                                </p:dataTable>
                            </p:fieldset>
                        </h:panelGroup>
                        <p:fieldset legend="Attendance Record">
                            <p:dataTable id="attendanceRecordTable" value="#{attendanceBean.attendanceRecordTableList}" var="attendanceRecord">
                                <p:column headerText="Date Attended">
                                    <h:outputText value="#{attendanceRecord.dateAttended}" />
                                </p:column>
                                <p:column headerText="Full Name">
                                    <h:outputText value="#{attendanceRecord.fullName}" />
                                </p:column>
                                <p:column headerText="Attended">
                                    <h:selectBooleanCheckbox value="#{attendanceRecord.attended}" readonly="true"/>
                                </p:column>
                            </p:dataTable>
                        </p:fieldset>
                    </h:panelGrid>
                </p:panel>
            </h:form>
        </ui:composition>
    </body>
</html>
